package com.woniuxy.oa.dao.provider;

import com.woniuxy.oa.entity.Role;
import org.apache.ibatis.jdbc.SQL;

/**
 * @description:
 * @author: guohao
 * @time: 2019/12/30 17:51
 */
public class RoleProvider {
    public String getSQL(Role role) {
        return new SQL() {
            {
                SELECT("*").FROM("oa_role");
                if (role != null) {
                    if (role.getRoleName() != null && role.getRoleName().trim().length() != 0) {
                        WHERE("roleName=#{roleName}");
                    }
                    if (role.getDescription() != null && role.getDescription().trim().length() != 0) {
                        WHERE("description=#{description}");
                    }
                    if (role.getStatus() != null && role.getStatus().trim().length() != 0) {
                        WHERE("status=#{status}");
                    }else {
                        WHERE("status=1");
                    }
                }
            }
        }.toString();
    }
}
